#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;

class Solution {
public:
    string makeGood(string s) {
        int left = 0, right = 1;
        if (right >= s.size())
            return s;
        while (right < s.size())
        {
            if (left < 0 || s[left] == ' ')
                left = right - 1;
            if ((s[left] + 32 == s[right]) ||
                (s[left] - 32 == s[right]))
            {
                s[left] = ' ';
                s[right] = ' ';
                left--;
                while (left >= 0 && s[left] == ' ')
                    left--;
                right++;
            }
            else
            {
                left++;
                right++;
            }
        }
        string ret;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] != ' ')
                ret.push_back(s[i]);
        }
        return ret;
    }
};

int main()
{
    string s("leEeetcode");
    Solution so;
    string ret = so.makeGood(s);
    cout << ret << endl;
    return 0;
}